package org.dr.st_docker.resource;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.Resource;


public class ResourceExample {
    public static void main(String[] args) {
        /**
         * ClassPathXmlApplicationContext获取Resource实例
         */
        // 访问类路径下的资源
        ApplicationContext ctx = new ClassPathXmlApplicationContext();
        // 获取类路径下的资源
        Resource res = ctx.getResource("bean.xml");
        // 输出资源信息
        System.out.println(res.getFilename());
/**
 * FileSystemApplicationContext获取Resource实例
 */
        ApplicationContext ctx1 = new FileSystemXmlApplicationContext();
        Resource res1 = ctx1.getResource("application.yml" );
        System.out.println(res1.getFilename());
    }
}

